package com.qfedu.fmmal.service;


import com.qfedu.fmmal.dao.UserDao;
import com.qfedu.fmmal.entity.User;
import com.qfedu.fmmal.vo.ResultVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl  implements UserService {

    @Resource
    private UserDao userDao ;


    @Override
    public ResultVo checklogin(String name, String pwd) {

        //根据账号查询用户信息
        User user = userDao.queryUserByName(name);

        if (user == null ) {
            return new ResultVo(1,"用户名不存在",null);
        } else {
            //对输入的密码进行加密
            //对加密的密码 和user中的密码进行匹配
            if (user.getUserPwd().equals(pwd)){
                //验证成功
                return new ResultVo(2,"登录成功",user);
            }else {
                //验证失败
                return new ResultVo(3 , "密码错误" , null);
            }
        }
    }
}
